import Opt from '@/components/dt/info/Opt.js'
import ruleOpt from '@/biz/option/rule.js'
import dt from '@dt/dt'
class NewOpt extends Opt {
  constructor(info) {
    super(info)
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.part1, this.reason)
  }

  createAll() {
    this.part1 = [
      {
        title: '案场名称',
        key: 'housesName',
        col: 20,
        text: {}
      },
      {
        title: '申请月份',
        key: 'applyMonth',
        col: 20,
        text: {}
      },

      {
        title: '延期原因',
        key: 'extendReason',
        col: 20,
        load: () => {
          if (this.info.extendReason == 'BUSINESS') {
            this.opts.remove(this.reason)
            this.opts.push(this.OAMsgNum)
            this.opts.push(this.reason)
          } else {
            this.opts.remove(this.OAMsgNum)
            this.opts.remove(this.reason)
            this.opts.push(this.reason)
          }
        },
        radio: {
          options: dt.dictInfo().bonusExtendReason
        },
        rules: [ruleOpt.required('请选择延期原因')],
        change: () => {
          if (this.info.extendReason == 'BUSINESS') {
            this.opts.remove(this.reason)
            this.opts.push(this.OAMsgNum)
            this.opts.push(this.reason)
          } else {
            this.opts.remove(this.OAMsgNum)
            this.opts.remove(this.reason)
            this.opts.push(this.reason)
          }
        }
      }
    ]
    this.OAMsgNum = {
      title: 'OA文电编号',
      placeholder: '请输入OA文电编号',
      key: 'oaNumber',
      col: 20,
      input: {},
      rules: [ruleOpt.required('请输入OA文电编号')]
    }
    this.reason = {
      title: '备注',
      col: 20,
      key: 'remark',
      input: {
        type: 'textarea',
        autosize: {
          minRows: 2
        }
      },
      rules: [ruleOpt.required('请输入原因'), ruleOpt.max(300)]
    }
  }
}

export default NewOpt
